﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace WishHand.Core
{
    public static class ProductHelper
    {
        public static IList<string> GetOutsiteLinkImgs(string html)
        {
            //SiteSettings siteSettings = YSContext.Current.SiteSettings;
            //SiteSettings masterSettings = SettingsManager.GetMasterSettings();
            IList<string> list = new List<string>();
            Regex regImg = new Regex(@"src[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)", RegexOptions.IgnoreCase);

            // 搜索匹配的字符串   
            MatchCollection matches = regImg.Matches(html);
            string[] sUrlList = new string[matches.Count];

            // 取得匹配项列表   
            foreach (Match match in matches)
            {
                if (!match.Groups["imgUrl"].Value.Contains("http"))
                {
                    continue;
                }
                list.Add(match.Groups["imgUrl"].Value.Replace(";", "").Replace("&quot", "").Trim());

            }
            return list;
        }
    }
}
